package com.chinasoft.maysham.manager.service;

import com.chinasoft.maysham.manager.util.HttpClient;
import com.chinasoft.maysham.manager.util.JacksonUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.Map;

@Service
@Slf4j
public class DockerHelper {
    private static final String PATH_INFO = "/info";

    @Resource
    private HttpClient httpClient;

    /**
     * 查询基本信息
     * @param baseUrl baseUrl
     * @return result
     */
    public Map<String, Object> info(String baseUrl) {
        String infoStr = httpClient.get(baseUrl + PATH_INFO, Collections.emptyMap());
        return JacksonUtil.toObj(infoStr, new TypeReference<Map<String, Object>>() {
        });
    }
}
